home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000090_icon-group-sender _Tue Nov 17 13:25:11 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 17 Nov 1992 14:42:10 MST
  2. Date: Tue, 17 Nov 1992 13:25:11 MST
  3. From: "Clint Jeffery" <cjeffery>
  4. Message-Id: <199211172025.AA26141@chuckwalla.cs.arizona.edu>
  5. To: Paul_Abrahams@MTS.cc.Wayne.edu
  6. Cc: icon-group@cs.arizona.edu
  7. In-Reply-To: Paul_Abrahams@MTS.cc.Wayne.edu's message of Tue, 17 Nov 92 10:50:06 EST <528466@MTS.cc.Wayne.edu>
  8. Subject: Field names of a record type
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12.    Paul Abrahams writes:
  13.    given the name of an Icon record type, is there a
  14.    straightforward way to list the names of its fields in the same order
  15.    as they appear in its definition?  So far I haven't found one.
  16.  
  17. While you are waiting for that built-in function, the following program
  18. demonstrates a technique that does what you ask.  Normally I wouldn't
  19. start from a *name* of a record type, but that's how you stated the problem.
  20. Folks who don't believe in semi-colon insertion, let me know if you have
  21. trouble reading this.
  22.  
  23. record r (alpha, beta, c)
  24.  
  25. procedure main()
  26.   every write(fieldnames("r"))
  27. end
  28.  
  29. procedure fieldnames(r)
  30.   R := r()
  31.   every i := 1 to *R do {
  32.     s := name(R[i])
  33.     suspend s[find(".",s)+1:0]
  34.   }
  35. end
  36.